<script setup lang="ts">
import { onMounted, nextTick, ref, watch } from 'vue'
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import en_GB from 'ant-design-vue/es/locale/en_GB';
import { RouterView } from 'vue-router'
import { DataViewState } from '/@/stores/RouterView'
import { Local } from '/@/units/Store';
import { getmark } from '/@/units/watermark'
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import { useI18n } from 'vue-i18n'
const { locale } = useI18n()

const { watermark } = getmark()

const localesinternationalization = ref<string>('zh-cn')

const DataView = DataViewState()
watch(() => DataView.ThemeConfig.internationalization, (newvalue: any) => {
  localesinternationalization.value = newvalue === 'zh-cn' ? 'zh-cn' : 'en_GB'
  ilan.value = localesinternationalization.value === 'zh-cn' ? zhCN : en_GB
  dayjs.locale(localesinternationalization.value);
})
const ilan = ref()
nextTick(() => {
  dayjs.locale(localesinternationalization.value);
  ilan.value = localesinternationalization.value === 'zh-cn' ? zhCN : en_GB
})

onMounted(() => {
  watermark('Vue-futuret-Admin')
  const ThemeJSOn: Theme = Local.get('ThemeConfig')
  nextTick(() => {
    if (ThemeJSOn) {
      document.documentElement.style.cssText = Local.get('ThemeConfigStyle')
      locale.value = ThemeJSOn.internationalization
      DataView.setThemofisettings(ThemeJSOn)
    }
  })
  // localesinternationalization.value = ThemeJSOn.internationalization
})
</script>

<template>
  <a-style-provider hash-priority="high">
    <a-config-provider :locale="ilan">
      <RouterView />
    </a-config-provider>
  </a-style-provider>
</template>

<style scoped lang="scss">
.wrapper {
  .cs {
    font-size: 44px;
  }
}
</style>
